public class Solution {
    //山峰数组的封顶元素
    public int peakIndexInMountainArray(int[] arr) {
        //第一个位置和最后一个位置不会在结果中
        int left = 1;
        int right = arr.length - 2;
        int mid = 0;
        while(left < right) {
            mid = left + (right - left + 1)/2;
            if(arr[mid] < arr[mid - 1]) {
                right = mid - 1;
            }
            if(arr[mid] > arr[mid - 1]) {
                left = mid;
            }
        }
        return left;
    }
}
